<script setup>
import { defineProps, ref } from 'vue'
const isPressed = ref(false)
const propGQ = defineProps({
  wenzi: String,
  canuse: Boolean
})
function suoxiao() {
  isPressed.value = true
}
function huifu() {
  isPressed.value = false
}
</script>

<template>
  <div
    class="anniu_container"
    :class="isPressed ? 'suoxiao' : ''"
    @mousedown="suoxiao()"
    @mouseup="huifu()"
  >
    <div class="active">
      <img class="icon" src="../assets/logo.png" alt="" />
      <div class="text">{{ propGQ.wenzi }}</div>
      <div class="an" @click="$emit('open-dati')">点击答题</div>
    </div>
    <div v-if="!canuse" class="inactive">
      <img class="icon" src="../assets/lock.png" alt="" />
    </div>
  </div>
</template>

<style lang="scss" scoped>
.anniu_container {
  width: 22vh;
  height: 28vh;
  background-image: linear-gradient(40deg, #00aef7 30%, #0173ed 60%, #015eea);
  box-sizing: border-box;
  position: relative;
  border-radius: 0.3vh;
  z-index: 1;
  transition: transform 0.25s;
  .active {
    width: 100%;
    height: 100%;
    position: absolute;
    left: 0;
    top: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 3;
    .icon {
      width: 8vh;
      height: 8vh;
      margin-bottom: 1vh;
    }
    .text {
      font-size: 2.5vh;
      margin-bottom: 2vh;
    }
    .an {
      width: fit-content;
      height: fit-content;
      font-size: 1.6vh;
      font-weight: bolder;
      padding: 0.5vh 2vh;
      background-image: linear-gradient(180deg, #fad545, #fad545, #ff6743);
      box-sizing: border-box;
      border: 0.3rem solid #fff;
      border-radius: 0.8rem;
      text-align: center;
    }
  }
  .inactive {
    width: 100%;
    height: 100%;
    position: absolute;
    left: 0;
    top: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background-color: #ffffff77;
    z-index: 4;
    .icon {
      width: 15vh;
      height: 15vh;
    }
  }
}
.suoxiao {
  transform: scale(0.95);
}
</style>
